gcc/g++ 多版本间切换 | 您所在的位置:网站首页 › linux 查看gcc › gcc/g++ 多版本间切换 |
1. 查看 gcc/g++ 版本查看当前版本gcc -v
g++ -v查看系统已有版本ls /usr/bin/gcc*
ls /usr/bin/g++* 若没有需要的版本,先进行安装,例如: sudo apt install gcc-4.9 sudo apt install g++-4.9 # 安装 gcc-7 / g++-7 sudo add-apt-repository ppa:ubuntu-toolchain-r/test sudo apt-get update sudo apt-get install gcc-7 sudo apt-get install g++-72. 手动切换先将需要的版本添加到 update-alternatives 中# gcc sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.9 40 sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-5 50 sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-7 70 # g++ sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.9 40 sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-5 50 sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-7 70若想删除,执行命令: sudo update-alternatives --remove gcc /usr/bin/gcc-4.9手动配置 update-alternativessudo update-alternatives --config gcc sudo update-alternatives --config g++手动输入想要切换版本的编号即可。 查看版本是否切换成功gcc -v g++ -v |
CopyRight 2018-2019 实验室设备网 版权所有 |